-- Handler getHyperLinkWords returns a list of the word
-- numbers in the hypertext link that were clicked on.
on getHyperLinkWords wordNumber
global currentTextCast
-- keep the list sorted
set hyperLinkWords = [wordNumber]
sort hyperLinkWords
set linkStyle = the textStyle of word wordNumber of field currentTextCast
set linkColor = the foreColor of word wordNumber of field currentTextCast
-- get all the words before the clickedWord that are part
-- of the hyperLink phrase.
repeat with i = (wordNumber - 1) down to 1
set theWord = word i of field currentTextCast
if (the textStyle of word i of field currentTextCast = linkStyle) and (the foreColor of word i of field currentTextCast = linkColor) and not(endsWithPunctuation(theWord)) then
add(hyperLinkWords, i)
else -- reached the beginning of the phrase
exit repeat
end if
end repeat
-- If the clickedWord does not end with punctuation,
-- get all the words after the clickedWord that are part
-- of the hypertext phrase.
if not(endsWithPunctuation(word wordNumber of field currentTextCast)) then
repeat with i = (wordNumber + 1) to the number of words in field currentTextCast
if (the textStyle of word i of field currentTextCast = linkStyle) and (the foreColor of word i of field currentTextCast = linkColor) then
add(hyperLinkWords, i)
if endsWithPunctuation(word i of field currentTextCast) then